﻿using KMF.Common;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace KMF.DAL
{
    public partial class ProductHotDb
    {
        public static int AddProductHot(ProductHotDto model)
        {
            var dao = SharedSqlDao;
            var command = dao.GetDbSprocCommand("WSPX_ProductHot_AddNew");
            try
            {
                command.Parameters.Add(dao.CreateParameter("@ProductId", model.ProductId));
                command.Parameters.Add(dao.CreateParameter("@EndDate", model.EndDate));
                command.Parameters.Add(dao.CreateParameter("@Show", model.Show));
                var result = command.ExecuteNonQuery();
                return result;
            }
            finally
            {
                command.Connection.Close();
            }
        }
        public static int DelAllProductHot()
        {
            var dao = SharedSqlDao;
            var command = dao.GetDbSprocCommand("WSPX_ProductHot_DelAll");
            try
            {
                var result = command.ExecuteNonQuery();
                return result;
            }
            finally
            {
                command.Connection.Close();
            }
        }
        public static List<ProductListForPagingDto> GetListAllProductHot()
        {
            var dao = SharedSqlDao;
            var command = dao.GetDbSprocCommand("WSPX_ProductHot_GetAll");
            try
            {
                var result = dao.GetDTOList<ProductListForPagingDto>(ref command);
                return result;
            }
            finally
            {
                command.Connection.Close();
            }
        }
    }
}
